<template>
  <div class="pageContent">
    <search-view @searchs="searchs" />
    <!-- 表格 -->
    <temlist :datas="datas" style="margin: 1vw 0 0" />
    <!-- 分页器 -->
    <el-pagination
      class="pagination"
      layout="slot,prev, pager, next"
      :total="pag.total"
      :current-page="pag.pageNo"
      :page-size="pag.pageSize"
      @current-change="handleCurrentChange"
    >
      <template slot="default">
        <div>
          <span>总共{{ pag.total }}条</span>
        </div>
      </template>
    </el-pagination>
  </div>
</template>

<script>
import SearchView from "./module/searchView.vue";
import temlist from "./module/temlist.vue";
export default {
  components: { SearchView, temlist },
  data() {
    return {
      pag: {
        pageNo: 1,
        pageSize: 5,
        total: 0,
      },
      datas: [],
      searches: {},
    };
  },
  created() {
    this.getlist({
      pageNo: 1,
      pageSize: 5,
      id: this.$store.state.user.info.id,
      role: this.$store.state.user.info.role,
    });
  },
  methods: {
    getlist(e) {
      this.$http.get("/getDailyAll", { params: e }).then((res) => {
        if (res.code == 200) {
          this.datas = res.data.data;
          this.pag.total = res.data.total;
        }
      });
    },
    //查询
    searchs(e) {
      this.searches = e;
      let obj = {
        pageNo: 1,
        pageSize: 5,
        id: this.$store.state.user.info.id,
      };
      obj = Object.assign(obj, e);
      console.log(obj);
      this.getlist(obj);
    },
    handleCurrentChange(e) {
      this.pag.pageNo = e;
      let obj = {
        pageNo: this.pag.pageNo,
        pageSize: 5,
        id: this.$store.state.user.info.id,
      };
      let queryRes = Object.assign(obj, this.searches);
      this.getlist(queryRes);
    },
  },
};
</script>

<style lang="scss" scoped>
@import url("../../styles/pages.scss");
</style>